<?php
// 获取一言API内容（仅桌面端使用）
function get_hitokoto()
{
    $url = 'https://v1.hitokoto.cn/';
    $response = @file_get_contents($url);

    if ($response) {
        $data = json_decode($response, true);
        return $data['hitokoto'] . ' —— ' . $data['from'];
    }

    return "简约设计，专注沟通 —— JIIL微聊";
}

$hitokoto = get_hitokoto();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JIIL微聊 - 简约登录</title>
    <meta name="description" content="JIILchat,简约高效的即时聊天系统">
    <link rel="icon" href="/favicon.ico" type="image/x-icon">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
        }

        body {
            min-height: 100vh;
            background: #ffffff;
            display: flex;
            flex-direction: column;
            padding: 0;
        }

        /* 移动端顶部标题 */
        .mobile-header {
            text-align: center;
            padding: 30px 20px 20px;
        }

        .mobile-title {
            color: #000;
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 30px;
        }

        /* 移动端内容区域 */
        .mobile-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 0 20px;
        }

        /* 按钮区域 */
        .button-group {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-top: 20px;
        }

        .btn {
            padding: 16px;
            border: none;
            border-radius: 8px;
            font-size: 18px;
            cursor: pointer;
            transition: all 0.2s ease;
            text-decoration: none;
            display: inline-block;
            font-weight: 500;
            text-align: center;
        }

        .login-btn {
            background: #000;
            color: white;
        }

        .register-btn {
            background: transparent;
            color: #000;
            border: 1px solid #ddd;
        }

        .login-btn:hover {
            background: #333;
        }

        .register-btn:hover {
            background: #f9f9f9;
        }

        /* 版权信息 */
        .footer {
            text-align: center;
            color: #999;
            font-size: 14px;
            padding: 20px 0;
        }

        /* 桌面端布局 - 默认隐藏 */
        .desktop-layout {
            display: none;
        }

        /* 媒体查询 - 桌面设备 */
        @media (min-width: 768px) {
            /* 隐藏移动端布局 */
            .mobile-layout {
                display: none;
            }
            
            /* 显示桌面端布局 */
            .desktop-layout {
                display: flex;
                min-height: 100vh;
                padding: 0;
            }
            
            /* 左侧图片区域 */
            .image-panel {
                flex: 1.5;
                background: #ffffff;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                padding: 40px;
                position: relative;
                overflow: hidden;
            }

            .image-container {
                width: 100%;
                max-width: 600px;
                height: 400px;
                border-radius: 12px;
                overflow: hidden;
                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
                background-color: #f9f9f9;
                display: flex;
                justify-content: center;
                align-items: center;
                border: 1px solid #f0f0f0;
            }

            .image-container img {
                width: 100%;
                height: 100%;
                object-fit: cover;
                transition: transform 0.5s ease;
            }

            .image-container img:hover {
                transform: scale(1.03);
            }

            .hitokoto {
                margin-top: 40px;
                text-align: center;
                max-width: 600px;
                padding: 20px;
                background: #ffffff;
                border-radius: 10px;
                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
                font-size: 18px;
                color: #333;
                line-height: 1.6;
                font-style: italic;
                position: relative;
                border: 1px solid #f0f0f0;
            }

            .hitokoto::before {
                content: """;
                font-size: 50px;
                position: absolute;
                top: -20px;
                left: 10px;
                color: rgba(0, 0, 0, 0.1);
            }

            .hitokoto::after {
                content: """;
                font-size: 50px;
                position: absolute;
                bottom: -40px;
                right: 10px;
                color: rgba(0, 0, 0, 0.1);
            }

            /* 右侧登录区域 */
            .login-panel {
                flex: 1;
                display: flex;
                justify-content: center;
                align-items: center;
                padding: 40px;
                background: #ffffff;
            }

            .container {
                background: #ffffff;
                padding: 40px;
                border-radius: 12px;
                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
                text-align: center;
                max-width: 400px;
                width: 100%;
                border: 1px solid #f0f0f0;
            }

            .logo {
                width: 80px;
                height: 80px;
                background: linear-gradient(135deg, #000000 0%, #333333 100%);
                border-radius: 50%;
                margin: 0 auto 20px;
                display: flex;
                align-items: center;
                justify-content: center;
                color: #fff;
                font-size: 40px;
                font-weight: bold;
                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            }

            h1 {
                color: #000;
                font-size: 28px;
                margin-bottom: 5px;
                font-weight: 600;
            }

            h2 {
                color: #666;
                font-size: 18px;
                margin-bottom: 30px;
                font-weight: 400;
            }

            .welcome-text {
                color: #333;
                font-size: 16px;
                margin-bottom: 30px;
                line-height: 1.6;
            }
        }
    </style>
</head>
<body>
    <!-- 移动端布局 -->
    <div class="mobile-layout">
        <div class="mobile-header">
            <div class="mobile-title">JIIL微聊</div>
        </div>
        
        <div class="mobile-content">
            <div class="button-group">
                <a href="login.php" class="btn login-btn">登录账号</a>
                <a href="register.php" class="btn register-btn">注册新账号</a>
            </div>
        </div>
        
        <div class="footer">
            © 2025 JIIL微聊 | JIILStudio版权所有
        </div>
    </div>
    
    <!-- 桌面端布局 -->
    <div class="desktop-layout">
        <div class="image-panel">
            <div class="image-container">
                <!-- 使用Picsum API获取随机图片 -->
                <img src="https://picsum.photos/600/400?random=1" alt="随机图片" id="random-image">
            </div>
            <div class="hitokoto" id="hitokoto-text">
                <?php echo htmlspecialchars($hitokoto); ?>
            </div>
        </div>
        
        <div class="login-panel">
            <div class="container">
                <div class="logo">J</div>
                <h1>JIIL微聊</h1>
                <h2>简约高效的沟通方式</h2>
                
                <div class="welcome-text">
                    随时随地与朋友保持联系<br>
                    简约设计，专注沟通
                </div>
                
                <div class="button-group">
                    <a href="login.php" class="btn login-btn">登录账号</a>
                    <a href="register.php" class="btn register-btn">注册新账号</a>
                </div>
                
                <div class="footer">
                    © 2025 JIIL微聊 | JIILStudio版权所有
                </div>
            </div>
        </div>
    </div>

    <script>
        // 仅桌面端执行图片和一言刷新
        if (window.innerWidth >= 768) {
            // 定时切换图片和一言
            function refreshContent() {
                // 更换图片
                const image = document.getElementById('random-image');
                const newImageUrl = `https://picsum.photos/600/400?random=${Math.floor(Math.random() * 1000)}`;
                image.src = newImageUrl;
                
                // 更换一言
                fetch('https://v1.hitokoto.cn/')
                    .then(response => response.json())
                    .then(data => {
                        const hitokotoText = document.getElementById('hitokoto-text');
                        hitokotoText.textContent = `${data.hitokoto} —— ${data.from}`;
                    })
                    .catch(error => {
                        console.error('获取一言失败:', error);
                    });
            }
            
            // 每30秒刷新一次内容
            setInterval(refreshContent, 30000);
            
            // 初始加载后立即刷新一次
            window.addEventListener('load', refreshContent);
        }
    </script>
</body>
</html>